home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_exmh.idb / usr / freeware / lib / exmh-2.5 / pgpEWN.tcl.z / pgpEWN.tcl
Text File  |  2002-07-08  |  2KB  |  85 lines

  1. # pgpEWN.tcl
  2.  
  3. # $Log: pgpEWN.tcl,v $
  4. # Revision 1.3  1999/08/13 00:39:05  bmah
  5. # Fix a number of key/passphrase management problems:  pgpsedit now
  6. # manages PGP versions, keys, and passphrases on a per-window
  7. # basis.  Decryption now works when no passphrases are cached.
  8. # One timeout parameter controls passphrases for all PGP
  9. # versions.  seditpgp UI slightly modified.
  10. #
  11. # Revision 1.2  1999/08/03 04:05:54  bmah
  12. # Merge support for PGP2/PGP5/GPG from multipgp branch.
  13. #
  14. # Revision 1.1.4.1  1999/06/14 20:05:15  gruber
  15. # updated multipgp interface
  16. #
  17. # Revision 1.3  1999/06/14 14:52:23  markus
  18. # Update ready
  19. #
  20.  
  21. proc EncryptWhatNow { v action id } {
  22.     global draft-folder mhProfile pgp
  23.  
  24.     set draft [Mh_Path $mhProfile(draft-folder) $id]
  25.     set tmp_draft [Mime_TempFile encrypt]
  26.  
  27.     set f_orig [open $draft r]
  28.     set f_tmp [open $tmp_draft w 0600]
  29.  
  30.     set hasfcc 0
  31.  
  32.     set line [gets $f_orig]
  33.     # while still in header
  34.     while {![regexp {^(--+.*--+)?$} $line]} {
  35.         if [regexp -nocase {^pgp-action:} $line] {
  36.             # we found an existing pgp-action line
  37.             # remove it
  38.             set line " dummy"
  39.             # while next lines start with tab or space
  40.             while {[regexp "^\[ \t]" $line]} {
  41.                 set line [gets $f_orig]
  42.             }
  43.         } else {
  44.             # other header lines
  45.             if [regexp -nocase {^fcc:} $line] {
  46.                 set hasfcc 1
  47.             }
  48.             puts $f_tmp $line
  49.             set line [gets $f_orig]
  50.         }
  51.     }
  52.     if {[set pgp($v,enabled)]} {
  53.         # build pgp-action: line
  54.         set pgpaction "Pgp-Action: $action"
  55.         if [set pgp($v,rfc822)] {
  56.             append pgpaction "; rfc822=on"
  57.         } else {
  58.             append pgpaction "; rfc822=off"
  59.         }
  60.         if [regexp {sign} $action] {
  61.             append pgpaction ";\n\toriginator=\"[lindex \
  62.                         [set pgp($v,myname,$id)] 1]\""
  63.         }
  64.         if [regexp {encrypt} $action] {
  65.             catch {
  66.                 append pgpaction "; \n\trecipients=\"[join [Pgp_Misc_Map key {lindex $key 1} [Pgp_Match_Whom $v $draft $hasfcc]] ",\n\t\t    "]\""
  67.             }
  68.         }
  69.         append pgpaction ";\n\tpgp-version=$v"
  70.         puts $f_tmp $pgpaction
  71.     } else {
  72.         # print warning
  73.         Exmh_Status "[set pgp($v,fullName)] not enabled" warn
  74.     }
  75.     # faster
  76.     puts $f_tmp $line
  77.     set remaining [read $f_orig]
  78.     puts -nonewline $f_tmp $remaining
  79.  
  80.     close $f_orig
  81.     close $f_tmp
  82.     # mv tmp to orig
  83.     catch {Mh_Rename $tmp_draft $draft}
  84. }
  85.